LCD INTERFACING WITH 8051
The LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on.
Synopsis

LCD (Liquid Crystal Display) screen is a display module and it is very commonly used. These modules are replacing LED seven segments and other multi segment LEDs. The LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. LCD can be easily interfaced with a microcontroller to display a message or status of a device.

Annotation

A liquid crystal display (LCD) is a flat panel display that uses the light modulating properties of liquid crystals (LCs). LCD Modules can present textual information to user. A 16×2 LCD module are consists of 16 rows and 2 columns of 5×7 or 5×8 LCD dot matrices. It is available in a 16 pin package with back light, contrast adjustment function and each dot matrix has 5×8 dot resolution .VEE pin is meant for adjusting the contrast of the LCD display and the contrast can be adjusted by varying the voltage at this pin. The 16×2 has two built in registers namely data register and command register. Data register is used for placing the data to be displayed, and the command register is used to place the commands. The 16×2 LCD module has a set of commands for doing a particular job with the display. High logic (1) at the RS pin will select the data register and Low logic (0) at the RS pin will select the command register. If we make the RS pin high and the put a data in the 8 bit data line (DB0 to DB7), the LCD module will recognize it as a data to be displayed. If we make RS pin low and put a data on the data line, the module will recognize it as a command.

VCC, VSS and VEE:

While VCC and VSS provide +5V and ground respectively, VEE is used for controlling LCD contrast.

RS (REGISTER SELECT):

There are two important registers inside the LCD. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data that is sent is a text data which should be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high.

RW (READ/WRITE):

The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands, so RW will almost be low.

EN (Enable):

The EN line is called "Enable". This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should first set this line high (1) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN low (0) again. The 1-0 transition tells the 44780 to take the data currently found on the other control lines and on the data bus and to treat it as a command.

D0-D7 (DATA LINES):

The 8-bit data pins, D0-D7 are used to send information to the LCD or read the content of the LCD’s internal registers. To display letters and numbers, we send ASCII codes for the letters A-Z, a-z and numbers 0-9 to these pins while making RS=1. There are also instruction command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor. We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive the information. The busy flag is D7 and can be read when R/W = 1 and RS=0, as follows: if R/W = 1, RS = 0. When D7=1 (busy flag = 1), the LCD is busy taking care of internal operations and will not accept any new information. When D7 = 0, the LCD is ready to receive new information.


Pin configuration:


LCD COMMAND CODES:


Programming the LCD:

• Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0. When busy flag=1, it means that LCD is not ready to accept data since it is busy with the internal operations. Therefore before passing any data to LCD, its command register should be read and busy flag should be checked.

• To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed on the positive edge of the Enable signal.

• To send a command on the LCD, a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.

Application Ideas:

• Professional-looking text and tone output on any microcontroller application

• Easy serial debugging without a PC

• Real-time sensor data output on autonomous robot

Proteus design for LCD interfacing with 8051


Orcad design for LCD interfacing with 8051


LCD interfacing with 8051

/*  Name     : main.c
 *  Purpose  : Source code for LCD Interfacing with AT89C52.
 *  Author   : Gemicates
 *  Date     : 2014-01-15
 *  Website  : www.gemicates.org
 *  Revision : None
 */
 
#include <REGX52.H>

#define Lcdport P
sbit rs = P3^7;  					       // register select pin
sbit rw = P3^6;  					       // read write pin
sbit en = P3^5;  					       // enable pin

//Function declarations 
void delay(unsigned int MS);
void lcdcmd_address(unsigned char cmd);
void lcddata(unsigned char send_data);
void lcd(unsigned char str[10]);
void lcd_data_string(unsigned char *str);

void main()
{
	lcdcmd_address(0x38);  				      // for using 8-bit 2 row mode and 5x7 Dots of LCD
	delay(10);
	lcdcmd_address(0x0E);  				      // turn display ON for cursor blinking
	delay(10);
	lcdcmd_address(0x0C);				      // Display On cursor Off	
	delay(10);
	lcdcmd_address(0x01);  				      // clear screen
	delay(10);
	lcdcmd_address(0x06);  				      // display ON
	delay(10);
	
	//	lcdcmd_address(0x08);  			      // display OFF
	//	delay(10);
	//	lcdcmd_address(0x0F);  			      // display On cursor blinking
	//	delay(10);
		
		lcdcmd_address(0x86);  			      // bring cursor to position 6 of ROW 1	
		lcddata('H');
		lcdcmd_address(0x87);  													
		lcddata('I');
		lcddata('!');
		delay(10);
		lcdcmd_address(0xC3);			      // bring cursor to position 3 of ROW 2
		lcd("**GUYS**");
		delay(50);
		lcdcmd_address(0x01);  			      // clear screen
		
	//	delay(10);
	//	lcdcmd_address(0x10);			      // move cursor left by one character
	//	delay(10);
	//	lcdcmd_address(0x14);			      // move cursor right by one character
	//	delay(10);
		
		lcdcmd_address(0x83);			      // bring cursor to position 3 of ROW 1
		lcd("WELCOME TO");
		delay(100);
		lcdcmd_address(0xC3);			      // bring cursor to position 3 of ROW 2
		lcd("GEMICATES");
		lcdcmd_address(0x01);  			      // clear screen
		
	while(1)
	{
		lcdcmd_address(0x80);										
		lcd("PROGRESS THROUGH");
		lcdcmd_address(0x1C);			      // shift entire display left
		lcdcmd_address(0xC3);										
		lcd("INNOVATION");
		lcdcmd_address(0x18);			      // shift entire display right
	}
}

void delay(unsigned int MS)  				      // Time delay function in milli seconds.
{
	int m,n;
	for(m=0; m<MS; m++)
	for(n=0;n<1275;n++);
}

void lcdcmd_address(unsigned char cmd)  	              // Function to send command to LCD
{
	Lcdport = cmd;
	rs= 0;
	rw= 0;
	en= 1;
	delay(5);
	en= 0;
	return;
}
  
void lcddata(unsigned char send_data)  		              // Function to send data to LCD
{
	Lcdport = send_data;
	rs= 1;
	rw=0;
	en=1;
	delay(5);
	en=0;
	return;
}
void lcd(unsigned char str[10])  	                      // Funtion to Initialize LCD
{
lcd_data_string(str);
}

void lcd_data_string(unsigned char *str)                      // Function to send string on LCD
{
int i=0;
	while(str[i]!='\0')
	{
		lcddata(str[i]);
		i++;
		delay(10);
	}
return;
}
Interfacing of LCD with 8051

Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close